home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13523 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.5 KB

  1. Path: bln.sel.alcatel.de!furguson
  2. From: furguson@bln.sel.alcatel.de (Marc Furguson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Coding Standards
  5. Date: 26 Mar 1996 13:45:19 GMT
  6. Organization: Alcatel SEL AG Berlin
  7. Message-ID: <4j8sdf$575@slbh00.bln.sel.alcatel.de>
  8. References: <4hj8ek$elu@sam.inforamp.net> <4hktar$5o2@galaxy.ucr.edu> <4io1a4$n9v@sam.inforamp.net>
  9. NNTP-Posting-Host: slbh37.bln.sel.alcatel.de
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Randy Charles Morin (rmorin@inforamp.net) wrote:
  13. : In article <CBARBER.96Mar18104644@figaro.bbn.com>,
  14. :    cbarber@bbn.com (Christopher Barber) wrote:
  15.     --- snip ---
  16. : >    Randy>     -a class which can be instantiated with a "new" must have a
  17. : >    Randy> copy constructor, a destructor and an assignment operator
  18. : >    Randy> definition.  Most compilers (if not all) supply default copy
  19. : >    Randy> construtors.  Unless you think your class may have copy behavior
  20. : >    Randy> problems, then writing copy constructors is redundant.  When you
  21. : >    Randy> have 100+ classes to write and where the average copy
  22. : >    Randy> constructor has 50 lines, you would need 100 hours to write the
  23. : >    Randy> additional robustness (or cumbersomeness).
  24. : >Aren't you getting a bit extreme here?  I have written hundreds of
  25. : >copy constructors and only a handful came even close to 50 lines long.
  26. : >Yes, the compiler will generate a copy constructor for you, but it
  27. : >has the wrong behavior in many cases.
  28.  
  29. : Where am I being a little extreme?  We do have 100+ classes, I have already 
  30. : identified about 100.  I calculated the average amount of lines per copy 
  31. : constructor in another project and it came out just below 50.  The average 
  32. : programmer on that project wrote less than 50 lines an hour.  That's 100 
  33. : hours.  It's math.
  34.     --- snip ---
  35. : Agrivar
  36.  
  37. Seems reasonable to me. It's not just a case of typing in copy constructors,
  38. destructors etc. If the compiler does it just fine then let it. If you need
  39. something else then code it, test it and document it. Now, maybe I'm just 
  40. slow but I take a *lot* longer to test and document my software than I 
  41. take to write it, so I'd rather not write it in the first place if I 
  42. don't have to! On the other hand if your code is completely self-
  43. documenting and is *always* faultless then just keep bashing away! 
  44. --
  45. +-----------------+--------------------------+
  46. | Mark Ferguson   | Alcatel SEL AG Berlin    |
  47. |                 | Mobile Comms Division    |
  48. |     aka         | Colditzstrasse 34-36     |
  49. | Marc Furguson   | D 12099 Berlin  Germany  |
  50. +-----------------+--------------------------+
  51.